<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        div {
            position: relative;
        }
        div::after {
            content: '';
            border-bottom: 1px solid #ccc;
            position: absolute;
            bottom: 0;
            left: 20px;
            right: 20px;
        }
    </style>
</head>
<body>
    <div>123123</div>

    <!-- 
        不用设置伪元素的width
         只要设置好left 和 right 伪元素会自动沾满剩下的宽度
     -->
</body>
</html>